<? 
	session_start(); 
	require("connect.php");
	$mal=$_REQUEST["lopid"];
	$thu=$_REQUEST["thuid"];
	$tiet=$_REQUEST["tietid"];
	$magv=$_REQUEST["magv"];
	$mamh=$_REQUEST["mamh"];
	$result=mysql_query("select * from thoikhoabieu where magv='{$magv}' and thu='{$thu}' and tiet='{$tiet}'");
	$result1=mysql_query("select * from giaovien where magv='{$magv}'");
	$r1=mysql_fetch_array($result1);
	if(mysql_num_rows($result)>0){
		$_SESSION["loithem"]="Giao vien ".$r1["hotendem"]."&nbsp;".$r1["ten"]." da day lop khac trong tiet hoc nay !";		
		header("Location:thoikhoabieu_admin_add.php?mal=$mal&thu=$thu&tiet=$tiet");	
	}else{
		$_SESSION["loithem"]="";		
		$sql="insert into thoikhoabieu(mal,thu,tiet,mamh,magv) values('{$mal}','{$thu}','{$tiet}','{$mamh}','{$magv}')";					
		mysql_query($sql) or die("Error!");		
		mysql_close();
		header("Location:thoikhoabieu_admin_detail.php?mal=$mal");
	}
	
?>